package zhaolongli_Controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import zhaolongli_Boundary.MyTextField;
import zhaolongli_Entity.Choice;
import zhaolongli_Entity.Model;

public class ChoiceController implements ActionListener {

	Model m;
	
	MyTextField tf;
	
	Choice choice;
	
	public ChoiceController(Model m, MyTextField tf ){
		this.tf = tf;
		this.m = m;		
	}
	
	public void actionPerformed(ActionEvent ae){
		String text = tf.getText();
		int tempIndex = tf.getIndex();
		choice = new Choice(text, tempIndex);
		m.addChoice(choice);
		tf.setEditable(false);

	}
	
}
